<template>
  <view style="padding-bottom: 120rpx;">
    <u-navbar
      v-if="!$isWeixin()"
      :customBack="backToList"
      :title="title"
      title-width="450"
      :titleBold="true"
      :background="{ backgroundColor: '#ffffff' }"
      :is-fixed="true"
    ></u-navbar>

    <u-tabs active-color="#FF7A23" :list="tabList" :current="tabIndex" @change="index => (tabIndex = index)"></u-tabs>

    <view class="" v-if="tabIndex === 0"><relations :list="state.This_Dealer_RelationList"></relations></view>

    <view class="" v-if="tabIndex === 1">
      <u-cell-item :arrow="false" title="一级经销商名称" :value="state.First_Dealer_BaseInfo.Name"></u-cell-item>
      <u-cell-item
        :border-bottom="false"
        :arrow="false"
        title="二级经销商名称"
        :value="state.Double_Dealer_BaseInfo.Name"
      ></u-cell-item>
      <store-information :data="state.Door_Dealer_BaseInfo"></store-information>
    </view>

    <view class="" v-if="tabIndex === 2">
      <store-renovation-information
        :showAuditRemark="false"
        :data="
          Object.assign(
            {
              EffectList: state.EffectList,
              RealList: state.RealList,
              Contract_PhotoList: state.Contract_PhotoList,
              Distribution_PhotoList: state.Distribution_PhotoList,
              Account: state.Double_Dealer_BaseInfo.Account
            },
            state.StoreRenovationApplyInfo
          )
        "
      ></store-renovation-information>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      title: '',
      tabList: [{ name: '销售业务关系' }, { name: '基本信息' }, { name: '专卖店信息' }],
      tabIndex: 0,

      StoreRenovationId: null,

      ApplyType: 1,

      state: {
        Door_Dealer_BaseInfo: {},
        Double_Dealer_BaseInfo: {},
        EffectList: [],
        First_Dealer_BaseInfo: {},
        RealList: [],
        Distribution_PhotoList: [],
        Contract_PhotoList: [],
        ShowLevel: null,
        StoreRenovationApplyInfo: {},
        This_Dealer_OtherInfo: {},
        This_Dealer_RelationList: []
      }
    };
  },

  onLoad(options) {
    if (options.StoreRenovationId) {
      this.StoreRenovationId = options.StoreRenovationId;
    }

    if (options.ApplyType) {
      this.ApplyType = options.ApplyType;

      if (options.ApplyType == 1) {
        this.title = '动力金审核详情';
      }
      if (options.ApplyType == 2) {
        this.title = '渠道补贴审核详情';
      }
    }

    this.init();
    if (this.$isWeixin()) {
      this.$setTitle(this.title);
    }
  },

  methods: {
    backToList() {
      uni.navigateBack();
    },

    init() {
      this.$u.api
        .getStoreRenovationReviewDetail({
          StoreRenovationId: this.StoreRenovationId,
          ApplyType: this.ApplyType
        })
        .then(res => {
          console.log(res);
          const { ResultCode, ResultMessage, ResultData } = res;
          if (ResultCode === 1) {
            this.state = ResultData;
          }
        });
    }
  }
};
</script>

<style lang="scss"></style>
